package com.ambulance.framework.task;

import com.ambulance.project.biz.entity.SysCache;
import com.ambulance.project.biz.service.SysCacheService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/***
 *  @description
 *  @author zhao
 *  @date: 2020/5/23
 *  @version: v1.0
 */
@Component(value = "sysCacheTask")
public class SysCacheTask {

    @Autowired
    private SysCacheService sysCacheService;

    /**
     * 定时删除过期数据
     */
    public void deleteCache() {
        QueryWrapper<SysCache> queryWrapper = new QueryWrapper<>();
        queryWrapper.lt("c_time", LocalDateTime.now());
        sysCacheService.remove(queryWrapper);

    }
}
